<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="books.storage.service.*"%>
<%@ page import="books.borrowing.entity.*"%>
<%@ page import="java.util.List"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type"
	content="text/html; charset=windows-1252" />
<title>Book Store</title>
<link rel="stylesheet" type="text/css" href="style.css" />

</head>
<body>
	<div id="wrap">

		<div class="header">
			<div class="logo">
				<a href="Elibrary"><img src="images/logo.gif" alt="" title=""
					border="0" /></a>
			</div>
			<div id="menu">
				<ul>
					<li><a href="/ELibrary">Accueil</a></li>
					<li><a href="/ELibrary/catalog">Consulter le catalogue</a></li>
					<% 
					SubscriberEntity user = (SubscriberEntity) session
					.getAttribute("user");
					if(user!=null) {
						out.println("<li><a href='/ELibrary/rent'>Voir mes emprunts</a></li>");
						out.println("<li class='selected'><a href='/ELibrary/edit_profile'>Modifier mon profil</a></li>");
					}
					%>
				</ul>
			</div>
		</div>


		<div class="center_content">
			<div class="left_content">
				<%
					String register_status = (String) session
							.getAttribute("register_status");
					session.setAttribute("register_status", null);
					String registerClass = "";
					String registerMessage = "";
					if (register_status == "FAILED"
							|| register_status == "FAILED_REGISTER") {
						String fail_message = (register_status == "FAILED") ? "Erreur lors de l'inscription, veuillez verifier tous les champs"
								: "Impossible d'inscrire l'utilisateur, existe t-il déja ?";
						registerClass = "style='border:1px dashed red;'";
						registerMessage = "<p style='color:red; font-weight:bold;'>"
								+ fail_message + "</p>";
					}

					String usr_name = (user != null) ? user.getName() : "";
					String usr_forname = (user != null) ? user.getForename() : "";
					String username = (user != null) ? user.getLogin() : "";
					String password = (user != null) ? user.getPassword() : "";
					
					if(user != null) {
						String usrMessage = (session.getAttribute("edit_profile_message")!=null) ? (String)session.getAttribute("edit_profile_message") : "";
						if(usrMessage.equals( "UPDATE_SUCCESS")) {
							out.println("<h3 style='color:green'>Profil mis a jour avec succes</font>");
						}
						session.setAttribute("edit_profile_message", "");
				%>

				<div class="contact_form" <%=registerClass%>>
					<div class="form_subtitle">Modifier mon compte</div>
					<form action="edit_profile" name="register" method="post">
						<%=registerMessage%>

						<div class="form_row">
							<label class="contact"><strong>Votre nom:</strong></label> <input
								type="text" name="usr_name" class="contact_input"
								value="<%=usr_name%>">
						</div>


						<div class="form_row">
							<label class="contact"><strong>Votre prénom:</strong></label> <input
								type="text" name="usr_forname" class="contact_input"
								value="<%=usr_forname%>">
						</div>


						<div class="form_row">
							<label class="contact"><strong>Votre
									identifiant:</strong></label> <input type="text" name="username"
								class="contact_input"
								value="<%=username%>">
						</div>

						<div class="form_row">
							<label class="contact"><strong>Mot de passe:</strong></label> <input
								type="password" name="password" class="contact_input"
								value="<%=password%>">
						</div>

						<div class="form_row">
							<input type="submit" value="Modifier" class="register">
						</div>
					</form>
				</div>
				<% } else {
					out.println("<center><h3 style='color:red;'>Vous devez être connecté pour afficher cette page</h3></center>");
				}
				%>


				<div class="clear"></div>
			</div>
			<!--end of left content-->

			<div class="right_content">

				<div class="right_box">

					<jsp:include page="login_form.jsp" />
				</div>


			</div>
			<div class="clear"></div>
		</div>
		<!--end of center content-->
		<div class="footer">
			<div class="left_footer">
				<img src="images/footer_logo.gif" alt="" title="" /><br /> <a
					href="http://csscreme.com/freecsstemplates/" title="free templates"><img
					src="images/csscreme.gif" alt="free templates"
					title="free templates" border="0" /></a>
			</div>
			<div class="right_footer">
				<a href="#">Accueil</a>

			</div>
		</div>
	</div>
</body>
</html>